const router = require("express").Router();
const UserController = require("../../../controllers/user");
const { Validate, user } = require("../../../validate");
const Auth = require("../../../middleware/auth");

// C端用户
router.post("/register", Validate(user.register), UserController.register);
router.post("/login", Validate(user.login), UserController.login);
// B端管理员
router.post(
    "/add",
    Auth.session,
    Validate(user.register),
    UserController.register
);
router.get("/logout", Auth.session, UserController.logout);
router.get("/list", Auth.session, Validate(user.list), UserController.list);
router.get("/:id", Auth.session, Validate(user.detail), UserController.detail);
router.delete(
    "/:id",
    Auth.session,
    Validate(user.delete),
    UserController.delete
);

module.exports = router;
